import { Post, Get, Put, Delete, Patch } from '@/utils/request.ts'

export interface paginationParamsType {
  pageNo: string | number
  pageSize: number | string
}

export interface CreateRoleDto {
  name?: string
  code?: string
  id?: number | string
}

export interface CreateUserDto {
  avatarFile?: never
  account: string
  password?: string
  username: string
  avatar?: string
  captchaId?: string // 新增：验证码 ID
  captchaCode?: string // 新增：验证码值
  roleId?: number | string
  role?: {id:number | string}
}

export const getUsersListApi = (data: paginationParamsType) => {
  return Get<paginationParamsType, Record<never, string>[]>('/blog/users', data)
}

export const deleteUsersApi = (id: string | number) => {
  return Delete<never, void>('/blog/users/' + id)
}

export const updateUserRoleApi = (userId: string, data: CreateRoleDto) => {
  return Post<CreateRoleDto, void>(`/blog/users/update/${userId}/role`, data)
}

export const updateUserApi = (id: string | number, data:CreateUserDto) => {
  return Patch<CreateUserDto, void>(`/blog/users/${id}`, data)
}
